<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>修改简历</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
    <style>
        html,
        body {
            font-size: 14px;
            height: 100%;
            background-color: #f2f2f2;
        }

        input {
            color: #666;
            font-size: 1rem;
            width: 60%!important;
            padding: 0!important;
            margin-bottom: 0!important;
            height: 100%!important;
            border: none!important;
            outline: 0;
        }

        header {
            position: fixed;
            top: 0;
            width: 100%;
            height: 75px;
            text-align: left;
            background-color: #fff;
            border-bottom: 1px solid #f2f2f2;
        }

        header .back {
            position: relative;
            margin-top: 38px;
            width: 100%;
            height: 1.5rem;
            text-align: center;
        }

        .back img {
            position: absolute;
            left: 1rem;
            width: 1.5rem;
            height: 1.5rem;
            vertical-align: middle;
        }

        main {
            padding-top: 75px;
        }

        .notice {
            padding: 1.5rem 0;
            color: #993333;
            font-weight: bold;
            text-align: center;
            background: url(../image/jianlibg.jpg)no-repeat;
            background-size: cover;
        }

        main .personinfo li {
            padding: 1rem;
            background-color: #fff;
            border-bottom: 1px solid #f2f2f2;
        }

        .personinfo li.workyear,
        .personinfo li.jobstatus {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        li.workyear .mui-input-row,
        li.jobstatus .mui-input-row {
            height: 100%;
        }

        .mui-input-row select {
            color: #666;
            margin: 0;
            font-size: 1rem!important;
        }

        .personinfo li span:nth-child(1) {
            margin-right: 1rem;
        }

        .personinfo li img {
            width: 16px;
            height: 16px;
            vertical-align: middle;
        }

        .save {
            width: 90%;
            margin: auto;
            margin-top: 1rem;
            text-align: center;
            line-height: 3;
            background-color: #FBB40E;
            border-radius: 0.35rem;
        }
    </style>
</head>

<body>
    <header>
        <div class="back">
            <img src="../image/icon/back.png" alt="" onclick="api.closeWin()">
            <span>修改简历</span>
        </div>
    </header>
    <main>
        <div class="notice">完善简历可以提高录取率哟</div>
        <ul class="personinfo">
            <li>
                <span>用户名：</span>
                <input type="text" id="uname" value="" placeholder="请输入用户名">
            </li>
            <li id="sex">
                <span>性别：</span>
                <span style="margin-right: 2rem">
                  <img src="../image/icon/selected.png" alt="" class="sex male">
                  <span>男</span>
                </span>
                <span>
                  <img src="../image/icon/selected1.png" alt="" class="sex female">
                  <span>女</span>
                </span>
            </li>
            <li>
                <span>年龄：</span>
                <input type="number" id="age" value="" placeholder="请输入年龄">
            </li>
            <li class="workyear">
                <span>工作年限</span>
                <div class="mui-input-row">
                    <select class="workyear-xz" name="">
                      <option value="0">无工作经验</option>
                      <option value="1">一到三年</option>
                      <option value="2">三到五年</option>
                      <option value="3">五年以上</option>
                    </select>
                </div>
            </li>
            <li>
                <span>微信：</span>
                <input type="text" id="wechat" value="" placeholder="请输入微信">
            </li>
            <li>
                <span>QQ：</span>
                <input type="number" id="qq" value="" placeholder="请输入QQ号" maxlength="10">
            </li>
            <li>
                <span>手机号：</span>
                <input type="number" id="phone" value="" placeholder="请输入手机号">
            </li>
            <li class="jobstatus">
                <span>求职状态：</span>
                <div class="mui-input-row">
                    <select class="jobstatus-xz" name="">
                      <option value="0">积极找工作</option>
                      <option value="1">随便看看</option>
                      <option value="2">暂时不考虑</option>
                    </select>
                </div>
            </li>
        </ul>
        <div class="save">保存</div>
    </main>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script src="../script/jquery-1.11.3.min.js" charset="utf-8"></script>
<script src="../script/mui.min.js" charset="utf-8"></script>
<script type="text/javascript">
    apiready = function() {

    };
    var sex = '男';
    var worktime = '无工作经验';
    var workstatus = '积极找工作';
    $('.sex').click(function() {
        $(this).attr("src", "../image/icon/selected.png").parent().siblings().find('img').attr("src", "../image/icon/selected1.png");
        sex = $(this).siblings().text();
    });

    $('#age').blur(function() {
        if ($(this).val() <= 18) {
            $(this).val('18')
        } else if ($(this).val() >= 60) {
            $(this).val('60')
        }
    })

    $('.workyear-xz').change(function() {
        worktime = $(this).find('option:selected').text();
    })

    $('.jobstatus-xz').change(function() {
        workstatus = $(this).find('option:selected').text();
    })

    $('.save').click(function() {
        var uname = $('#uname').val();
        var age = $('#age').val();
        var wechat = $('#wechat').val();
        var qq = $('#qq').val();
        var phone = $('#phone').val();
        var telStr = /^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/;
        if (uname && age && wechat && qq && phone) {
          if (!(telStr.test(phone))) {
              api.toast({
                  msg: '手机号码不规范',
                  duration: 2000,
                  location: 'bottom'
              });
              return
          }
            api.ajax({
                url: 'http://122.112.138.133/wangt/jianzhi/updateUserInfo.com',
                method: 'post',
                data: {
                    body: {
                        "tbname": "userinfo",
                        "id": $api.getStorage('userid'),
                        "username": uname,
                        "sex": sex,
                        "age": age,
                        "phone": phone,
                        "wechat": wechat,
                        "qq": qq,
                        "workstatus": workstatus,
                        "worktime": worktime
                    }
                }
            }, function(ret, err) {
                if (ret) {
                    $api.setStorage('username', uname);
                    api.closeWin({
                        name: 'main'
                    });
                    api.openWin({
                        name: 'main',
                        url: './main.html',
                        slidBackEnabled: false
                    });
                    setTimeout(function(){
                      api.closeWin({
                          name: 'myresume'
                      });
                    },1000)
                }
            });
        } else {
            api.toast({
                msg: '请填写完所有信息再保存',
                duration: 2000,
                location: 'bottom'
            });
            return
        }
    })
</script>

</html>
